import { http } from "@/utils/http";
import type { PageData, PageParam, Request, Response } from "@/api";
import type {
  CodeMapSelect,
  CodeMapData,
  CodeMapSearch,
  CodeMapUpsert
} from "@/api/dict";

const service = "dict";

/** 代码映射搜索 @DaoDao 代码映射搜索 POST /api/code-map-search */
export async function codeMapSearch(
  request: Request<PageParam<CodeMapSearch>>
): Promise<Response<PageData<CodeMapData>>> {
  return http.post<
    Request<PageParam<CodeMapSearch>>,
    Response<PageData<CodeMapData>>
  >(`${service}/api/code-map-search`, { data: request });
}

/** 代码映射查询 @DaoDao 代码映射查询 POST /api/code-map-select */
export async function codeMapSelect(
  request: Request<CodeMapSelect>
): Promise<Response<CodeMapData>> {
  return http.post<Request<CodeMapSelect>, Response<CodeMapData>>(
    `${service}/api/code-map-select`,
    { data: request }
  );
}

/** 代码映射写入 @DaoDao 代码映射写入 POST /api/code-map-upsert */
export async function codeMapUpsert(
  request: Request<CodeMapUpsert>
): Promise<Response<CodeMapData>> {
  return http.post<Request<CodeMapUpsert>, Response<CodeMapData>>(
    `${service}/api/code-map-upsert`,
    { data: request }
  );
}
